<template>
  <div class="pagination">
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage1"
      layout="total, prev, pager, next, slot"
      :total="total"
      :page-size="pageSize"
    >
      <div class="handlePage clearfix">
        <div class="fl handlePage_l">到第</div>
        <div class="shuru fl">
          <el-input
            v-model="currentPage2"
            class="pageInput"
            oninput="value=value.replace(/\D/g,'')"
          ></el-input>
        </div>
        <div class="fl handlePage_r">页</div>
        <div class="button pointer fl" @click="goPage">确定</div>
      </div>
    </el-pagination>
  </div>
</template>
<script>
export default {
  props: {
    total: {
      type: Number,
      default: 0,
    },
    pageSize: {
      type: Number,
      default: 15,
    },
    totalPage: {
      type: Number,
      default: 0,
    },
    currentPage:{
      type: Number,
      default: 1,
    }
  },
  watch: {
    total(newValue, oldValue) {
      this.total = newValue;
    },
    currentPage(newValue, oldValue){
      this.currentPage = newValue;
      this.currentPage1 = newValue;
    }
  },
  data() {
    return {
      currentPage1: this.currentPage,
      currentPage2:'',
    };
  },
  methods: {
    handleCurrentChange(obj) {
      this.$emit("handleCurrentChange", obj);
    },
    goPage(val) {
      if (this.currentPage1 && this.totalPage > this.currentPage1) {
        this.currentPage1 = this.currentPage2 * 1;
        this.$emit("goCurrentPage", this.currentPage2 * 1);
      }
    },
    handleSizeChange(val) {
      console.log("11111", val);
    },
  },
};
</script>
<style lang="less" scoped>
.pagination {
  text-align: center;
  position: relative;
  /deep/.handlePage {
    display: inline-block;
    .is-background {
      background-color: blue;
    }
    .handlePage_l,
    .handlePage_r {
      font-size: 12px;
      color: #303133;
      line-height: 28px;
      margin: 0 10px;
    }
    .shuru {
      font-size: 12px;
      color: #303133;
      line-height: 28px;
      .el-input__inner {
        width: 28px;
        height: 28px;
        padding: 0 2px;
      }
    }
    .button {
      line-height: 26px;
      width: 40px;
      height: 26px;
      border: 1px solid #dedede;
      border-radius: 2px;
      text-align: center;
      font-size: 12px;
      cursor: pointer;
      &:hover {
        color: #409eff;
      }
    }
  }
}
</style>
